<template>
  <div>
    当前权限：
    <div v-for="(value,key) in rights" :key="key">
      {{ key }} - {{ value }}
    </div>
    <div class="ls-text-line">
      <el-button @click="getModuleRight">从服务器获取权限</el-button>
    </div>
  </div>
</template>

<script lang="ts">
import Vue from "vue";
import {getDefaultRight, getModuleCodeFromQuery, getRight} from "./GetButtonRight";

export default Vue.extend({
  name: "GetButtonRightTest",
  data() {
    return {
      rights: getDefaultRight()
    }
  },
  methods: {
    async getModuleRight() {
      const moduleCode = getModuleCodeFromQuery(this.$route.query);
      if (moduleCode) {
        const rights = await getRight(moduleCode);
        if (rights) {
          this.rights = rights;
        }
      }
    }
  }
})
</script>

<style scoped>

</style>
